//单词的划分
#include <iostream>
#include <cstring>

using namespace std;
const int MAXL=100;
const int MAXN=100;
char s[MAXL+1];
char words[MAXN+1][MAXL+1];
int n;

int wordlens[MAXN+1];
int minnum[MAXL+1][MAXL+1];
bool compare(char s1[],int start,int end,char s2[]){
    //cout<<s1<<' '<<s2;
    for(int i=start;i<=end;i++){
        if (s1[i]!=s2[i-start]) return false;
    }
    return true;
}
int main(){
    cin>>s;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>words[i];
    int l=strlen(s);
    //初始化动规数组
    for(int i=0;i<l;i++)
        for(int j=i;j<l;j++) minnum[i][j]=100;
    
    for(int i=1;i<=n;i++){
        wordlens[i]=strlen(words[i]);
        for(int start=0;start<l-wordlens[i]+1;start++){
            int end=start+wordlens[i]-1;
            if (compare(s,start,end,words[i])) minnum[start][end]=1;
        }
    }

    
    
    for(int k=1;k<=l-1;k++)
        for(int i=0;i<l-k;i++){
            int j=i+k;
            for(int mid=i;mid<j;mid++)
                if (minnum[i][j]>minnum[i][mid]+minnum[mid+1][j])
                    minnum[i][j]=minnum[i][mid]+minnum[mid+1][j];
        }
    
    cout<<minnum[0][l-1];

}
